package br.com.massai.model.entity.pojo;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import br.com.massai.controller.annotations.Pojo;

@Embeddable
public class BudgetItem implements Serializable {

	private static final long serialVersionUID = 4496768211019837290L;

	@Column(name = "BUDGETITEM_CDOBRA", nullable = false, columnDefinition = "INTEGER")
	private Integer cdObra;
	
	@Column(name = "BUDGETITEM_NUVERSAO", nullable = false, columnDefinition = "INTEGER")
	private Integer nuVersao;
	
	@Column(name = "BUDGETITEM_CDUNIDCONSTOBRA", nullable = false, columnDefinition = "INTEGER")
	private Integer cdUnidConstObra;
	
	@Column(name = "BUDGETITEM_NUSEQUENCIAL", nullable = false, columnDefinition = "INTEGER")
	private Integer nuSequencial;
	
	@Column(name = "BUDGETITEM_CDTABELA", nullable = false, columnDefinition = "INTEGER")
	private Integer cdTabela;
	
	@Pojo
	@Column(name = "BUDGETITEM_CDREFERENCIA", nullable = false, columnDefinition = "VARCHAR(20)")
	private String cdReferencia;
	
	@Column(name = "BUDGETITEM_DEPLANILHA", nullable = false, columnDefinition = "VARCHAR(255)")
	private String dePlanilha;
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null) return false;

		if(obj instanceof BudgetItem)
			if(((BudgetItem)obj).cdReferencia.equals(this.cdReferencia)) return true;
		
		return false;
	}

	public Integer getCdObra() {
		return cdObra;
	}

	public void setCdObra(Integer cdObra) {
		this.cdObra = cdObra;
	}

	public Integer getNuVersao() {
		return nuVersao;
	}

	public void setNuVersao(Integer nuVersao) {
		this.nuVersao = nuVersao;
	}

	public Integer getCdUnidConstObra() {
		return cdUnidConstObra;
	}

	public void setCdUnidConstObra(Integer cdUnidConstObra) {
		this.cdUnidConstObra = cdUnidConstObra;
	}

	public Integer getNuSequencial() {
		return nuSequencial;
	}

	public void setNuSequencial(Integer nuSequencial) {
		this.nuSequencial = nuSequencial;
	}

	public Integer getCdTabela() {
		return cdTabela;
	}

	public void setCdTabela(Integer cdTabela) {
		this.cdTabela = cdTabela;
	}

	public String getCdReferencia() {
		return cdReferencia;
	}

	public void setCdReferencia(String cdReferencia) {
		this.cdReferencia = cdReferencia;
	}

	public String getDePlanilha() {
		return dePlanilha;
	}

	public void setDePlanilha(String dePlanilha) {
		this.dePlanilha = dePlanilha;
	}

	public String getDescriptionComplete() {
		if(this.cdReferencia != null && !this.cdReferencia.isEmpty() && this.dePlanilha != null && !this.dePlanilha.isEmpty())
			return this.cdReferencia + " - " + this.dePlanilha;
		return "";
	}
}
